<template>
  <div class="home">
    <!-- 导航栏 -->
    <navroot @conditionType="selectType" @getScore="selectScore" @getDate="selectDate" @getWord="selectWord"
      @getTag="selectTag" @openCapture="isShowModal1 = true" @openTypeConfig="isTypeConfig = true"
      @openTagConfig="isTagConfig = true" :checkedDatas="checkedDatas" />
    <!-- 项目详情页 -->
    <popUp v-if="isShowModal">
      <projectDetails @update="upDate" @close="isShowModal = false" :getItem="detail" @transmit="projectData"  :prodata="proData"/>
    </popUp>
    <!-- 项目抓取页 -->
    <popUp v-if="isShowModal1">
      <capture @closeCapture="isShowModal1 = false" @openLoadding="isLoadding = true" />
    </popUp>
    <!-- 额外属性配置页 -->
    <popUp v-if="isShowAttibute">
      <attribute @closeAttibute="isShowAttibute = false" />
    </popUp>
    <!-- 类型配置页 -->
    <popUp v-if="isTypeConfig">
      <typeConfig @closeTypeConfig="isTypeConfig = false" />
    </popUp>
    <!-- 标记配置页 -->
    <popUp v-if="isTagConfig">
      <tagConfig @closeTagConfig="isTagConfig = false" />
    </popUp>
    <popUp v-if="isLoadding">
      <loadding @closeLoadding="isLoadding = false" />
    </popUp>
    <!-- 表格 -->
    <div id="content" v-if="isShow">
      <projectTable @isShowDetail="isShowModal = true" @isAttribute="isShowAttibute = true" @project="getDetail"
        :getType="type" :getTag="tag" :getScore="score" :getDate="date" :getWord="keyword"
        @getCheckedDatas="getCheckedDatas" :prodata="proData"/>
    </div>
  </div>
</template>

<script>
import navroot from "@/components/nav/nav.vue";
import projectDetails from "@/components/projectDetails/projectDetails.vue";
import capture from "@/components/capture/capture.vue";
import projectTable from "@/components/table/table.vue";
import popUp from "@/components/popUp/popUp.vue";
import attribute from "@/components/attributeConfig/attributeConfig.vue";
import typeConfig from "@/components/typeConfig/typeConfig.vue";
import tagConfig from "@/components/tagConfig/tagConfig.vue";
import loadding from "@/components/loadding/loadding.vue"

export default {
  components: {
    navroot,
    projectDetails, //详情页
    capture, //项目抓取页
    projectTable, //表格
    popUp,
    attribute, //额外属性配置页
    typeConfig, //类型配置页
    tagConfig, //标记配置
    loadding,  // 进度页面
  },
  name: "home",
  data() {
    return {
      isShow:false,
      proData:null,
      isShowModal: false, //详情页
      isShowModal1: false, //项目抓取页
      isShowAttibute: false, //额外属性配置页
      isTypeConfig: false, //类型配置页
      isTagConfig: false, //标记配置
      isLoadding: false,  //项目抓取进度页

      // 子组件传来的值
      type: "", //类型
      detail: "", //详情
      score: "", //分数
      tag: "", //标记
      date: "", //日期
      keyword: "", //关键字
      checkedDatas: []  //已选择的表格数据
    };
  },
  async mounted() {
    this.getData()
    let token = window.localStorage.getItem('LESSONPLAY_TOKEN');
    if (!token) {
      location.href =  `http://${window.location.host}/`;
    }
  },
  methods: {
    upDate(){
      this.getData()
    },
  async  getData(){
    let res = await this.$api.projectMessage.project();
    if(res.code!=="success"){
      console.log("获取失败")
    }
    else{
      this.isShow=true
      this.proData=res

    }
    },
    showDetail(detail) {
      this.isShowModal = detail;
    },
    // 项目详情
    getDetail(item) {
      this.detail = item;
      console.log(this.detail);
    },
    //类型
    selectType(type) {
      this.type = type;
    },
    // 标记
    selectTag(tag) {
      this.tag = tag;
    },
    // 评分
    selectScore(score) {
      this.score = score;
    },
    // 日期
    selectDate(date) {
      this.date = date;
      // console.log('home的',this.date)
    },
    // 关键字
    selectWord(keyword) {
      this.keyword = keyword;
    },
    // 已选择的表格数据
    getCheckedDatas(checkedDatas) {
      this.checkedDatas = checkedDatas
    },
    // 接收项目详情传过来的项目信息
    projectData(data) {
      console.log("项目信息", data);
    }
  },
};
</script>

<style scoped lang="scss">
@import "./home.scss";
</style>
